package net.adetech.cjg.innerservice.mapper;

import net.adetech.cjg.innerservice.entity.Bzhzrw;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface BzhzrwDao {


    @Insert("insert into cjg_bzhzrw (id, sfzmhm, djzsxzqh, djzsxxdz, lxzsxzqh, lxzsxxdz, sjhm, org_code, rwzt, create_time,ywyy,client_id,sfzyxqs,sfzyxqz,xm) " +
            " values (#{id}, #{sfzmhm}, #{djzsxzqh}, #{djzsxxdz}, #{lxzsxzqh}, #{lxzsxxdz}, #{sjhm}, #{orgCode}, '0', sysdate,#{ywyy},#{clientId},#{sfzyxqs},#{sfzyxqz},#{xm})")
    void saveBzhzrw(Bzhzrw bzhzrw);


    @Select("select b.* from CJG_BZHZRW b,CJG_ZDZS r,CJG_ZS z where b.RWZT = '0' and b.create_time > sysdate - 2/(60*24) and b.YWYY not like '%B%' and b.CLIENT_ID = r.ZDID and r.ZSID = z.ID and z.IP = #{ip} order by create_time asc")
    Bzhzrw getBzhzrwByIp(String ip);



    @Select("select * from cjg_bzhzrw where id = #{id}")
    Bzhzrw getBzhzrwById(String id);


    @Update("update cjg_bzhzrw set rwzt = #{rwzt} , bz = #{bz} where id = #{id}")
    void updateBzhzrwzt(Bzhzrw bzhzrw);
}
